Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

translation/rotation gridding #192

Merged
merged 7 commits into from
Sep 25, 2024
Merged

translation/rotation gridding #192

merged 7 commits into from
Sep 25, 2024

Conversation

karen-sy
Copy link
Collaborator

@karen-sy karen-sy commented Sep 19, 2024

Implements

    grid = pose_grid(
        pose0,   # center of grid
        min_x=min_x,    # translation min/max ranges (x,y,z)
        min_y=min_y,
        min_z=min_z,
        max_x=max_x,
        max_y=max_y,
        max_z=max_z,
        nx=nx,     # translation number of grid points (x,y,z)
        ny=ny,
        nz=ny,
        min_euler_angle=min_euler,     # rotation min/max ranges (x,y,z)
        max_euler_angle=max_euler,
        n_xrot=n_xrot,    # rotations around x axis 
        n_yrot=n_yrot,
        n_zrot=n_zrot,
    )

Which produces a uniform translation/rotation grid from a center pose. (Make small note that this is different from the old Bayes3D rotation gridding scheme based on Ben Zinberg's fibonacci lattice division.)

Script also contains a test for visually sanity checking the grid poses on rerun; this code can be moved out/deleted.

Perf benchmark with jax.jit: Time taken: 0.6721019744873047 milliseconds for 15625 poses

@georgematheos
Copy link
Collaborator

@karen-sy this looks great!

I just played around with a bit and tried to add a visual to view the pose grids by displaying "axis arrows" at each grid point. Currently, it looks like the original pose is not at the center of the pose grid, but at the bottom of it. Could you please take a look at this and check if this is right, or if my visualization is erroneous? (It may well be...) If this is right, can you please change the gridding code to ensure the original pose is at the grid center?

Also, it also looks like when the rotation grid has only 1 grid point, it ends up being rotated relative to the original pose, rather than having the same rotation to the original pose. This may again be an issue with my visualization, but if it is a real property of the pose grid, I think it would be better to ensure that with small rotation grids, we cover the original rotation exactly.

Screenshot 2024-09-19 at 9 32 24 AM

@karen-sy
Copy link
Collaborator Author

karen-sy commented Sep 19, 2024

Also, it also looks like when the rotation grid has only 1 grid point, it ends up being rotated relative to the original pose, rather than having the same rotation to the original pose. This may again be an issue with my visualization, but if it is a real property of the pose grid, I think it would be better to ensure that with small rotation grids, we cover the original rotation exactly.

This is likely from default jnp.linspace behavior -- I'll modify the grid ordering so that we order the close points (to center) first. Re: viz, let me check again

@karen-sy
Copy link
Collaborator Author

karen-sy commented Sep 19, 2024

I modified the gridding API such that every grid is guaranteed to have the original pose included:

def pose_grid(
    pose_center: Pose,   # center pose (will always be in returned Pose)
    half_dx=float,          # HALF dimension size of grid (i.e. if we want to grid over range [-n, n] for n>=0, then half_dx = n)
    half_dy=float,
    half_dz=float,
    half_nx=int,             # number of gridding points in HALF dimension (i.e. if we want 2k points in a grid of [-n,n], half_nx = k)
    half_ny=int,
    half_nz=int,
    half_dangle=float,
    half_n_xrot=int,       
    half_n_yrot=int,
    half_n_zrot=int,
) -> Pose

Perf benchmark: Time taken: 0.6334781646728516 milliseconds for 15625 poses

Also, not exactly sure what you were exactly visualizing; could you toggle VIZ_TEST on L168 to True and see the mug + axes that are visualized on rerun? (@georgematheos )

Copy link
Collaborator

@georgematheos georgematheos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@karen-sy this looks great! I moved the tests to the tests/ directory and added a docstring -- if this looks good to you and all the tests in tests/gen3d are passing for you, please merge this to gen3d!

@karen-sy
Copy link
Collaborator Author

Oops somehow I thought you merged the branch already! Thanks so much for doing the test refactoring. Merging!

@karen-sy karen-sy merged commit 4273a6b into gen3d Sep 25, 2024
5 of 7 checks passed
@karen-sy karen-sy deleted the karenc/gridding branch September 25, 2024 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants